package com.ylbh.modules.reply.controller;

import com.ylbh.common.annotation.SysLog;
import com.ylbh.common.pojo.reply.dto.AddOrModifyReplyDTO;
import com.ylbh.common.pojo.reply.dto.CommunalDTO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.reply.entity.ShoppingReply;
import com.ylbh.modules.reply.service.ShoppingReplyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 回复管理
 * @author wjc
 * @date 2019-10-17 11:04:15
 */
@RestController
@RequestMapping("reply")
public class ShoppingReplyController {

    @Autowired
    private ShoppingReplyService shoppingReplyService;

    @ApiOperation("帮助回复问题配置列表")
    @RequestMapping("queryReplyList")
    public CommonResult<PageUtils> queryReplyList(CommunalDTO replyDTO){
        PageUtils replyList = shoppingReplyService.queryReplyList(replyDTO);
        return Ref.ok(replyList);
    }

    @ApiOperation("新增回复表数据")
    @RequestMapping("addNewReply")
    public CommonResult addNewReply(@RequestBody AddOrModifyReplyDTO addOrModifyReplyDTO){
        shoppingReplyService.addNewReply(addOrModifyReplyDTO);
        return Ref.ok();
    }

    @SysLog("根据ID回显回复信息")
    @ApiOperation("根据ID回显回复信息")
    @GetMapping("getReplyById/{replyId}")
    public  CommonResult getReplyById(@PathVariable String replyId) {
        ShoppingReply shoppingReply  = shoppingReplyService.getReplyById(replyId);
        return Ref.ok(shoppingReply);
    }

    @SysLog("根据ID修改回复表信息")
    @ApiOperation("根据ID修改回复信息")
    @RequestMapping("modifyReplyById")
    public  CommonResult modifyReplyById(@RequestBody AddOrModifyReplyDTO addOrModifyReplyDTO) {
        shoppingReplyService.modifyReplyById(addOrModifyReplyDTO);
        return Ref.ok();
    }

    @SysLog("删除回复表信息")
    @ApiOperation("删除回复表信息")
    @RequestMapping("removeReplyByIds")
    public CommonResult<Void> removeReplyByIds(@RequestBody String[] Ids){
        shoppingReplyService.removeReplyByIds(Arrays.asList(Ids));
        return Ref.ok();
    }

    @SysLog("修改回复表问题配置状态")
    @ApiOperation("修改回复表问题配置状态")
    @RequestMapping("modifyReplyEnableStateById")
    public CommonResult<Void> modifyReplyEnableStateById(@RequestBody CommunalDTO communalDTO){
        shoppingReplyService.modifyReplyEnableStateById(communalDTO);
        return Ref.ok();
    }

    @SysLog("修改回复表推荐状态")
    @ApiOperation("修改回复表推荐状态")
    @RequestMapping("modifyReplyRecommendStateById")
    public CommonResult<Void> modifyReplyRecommendStateById(@RequestBody CommunalDTO communalDTO){
        shoppingReplyService.modifyReplyRecommendStateById(communalDTO);
        return Ref.ok();
    }

    @SysLog("批量修改回复表状态")
    @ApiOperation("批量修改回复表状态")
    @RequestMapping("modifyReplyEnableStateByIds/{batchValue}")
    public CommonResult<Void> modifyReplyEnableStateByIds(@PathVariable String batchValue,@RequestBody String[] Ids){
        shoppingReplyService.modifyReplyEnableStateByIds(batchValue,Ids);
        return Ref.ok();
    }
}
